#include"../include/img.h"

int main(int argc, char const *argv[])
{
    void *handle = NULL;
    if(strstr( argv[1], ".jpeg") || strstr(argv[1], ".jpg")){
        handle = dlopen("libjpg.so", RTLD_NOW);
        if(handle == NULL){
        printf("加载动态库[%s]失败:%s\n", "libjpg.so", strerror(errno));
        return 0;    
        }
    }
    else if(strstr(argv[1], ".bmp")){
        handle = dlopen("libbmp.so", RTLD_NOW);
        if(handle == NULL){
        printf("加载动态库[%s]失败:%s\n", "libjpg.so", strerror(errno));
        return 0;    
        }
    }
    void (*detect)(const char*, uint8_t);
    detect = dlsym(handle, "display_img");
    if(detect == NULL){
        printf("查找函数[%s]失败:%s\n", "display_img", strerror(errno));
        return 0;
    }
    detect(argv[1], ZOOM|CENTER);
    dlclose(handle);
    return 0;
}